/* 
 * File:   Texture.h
 * Author: johannes
 *
 * Created on January 4, 2014, 3:00 AM
 */

#ifndef TEXTURE_H
#define	TEXTURE_H

#include <SDL2/SDL.h>
#include "Renderer.h"

namespace GUL {
    namespace System {
        namespace Graphic {

            class Texture {
            private:

                SDL_Texture*            m_Texture;
                Renderer&               m_TextureRenderer;
                
                std::string             m_name;

            protected:

                Texture();
                Texture(Texture&);

            public:

                Texture(Renderer&, SDL_Texture*, const std::string& name);
                Texture(Renderer&, UPair& Boundary, const std::string& name, Uint32 format, int access);
                Texture(Renderer&, Surface&, const std::string& name);
                Texture(Renderer&, SDL_Surface*, const std::string& name);
                virtual ~Texture();

                void QueryTexture( Uint32*, UPair& Boundary);

                void ColorMod(SDL_Colour);
                SDL_Colour& ColorMod();
                void AlphaMod(Uint8);
                Uint8 AlphaMod();
                void BlendMode(SDL_BlendMode);
                SDL_BlendMode& BlendMode();

                void Update(const SDL_Rect*, const void* pixel, int pitch);
                void UpdateYUVTexture(const SDL_Rect * rect,
                        const Uint8 *Yplane, int Ypitch,
                        const Uint8 *Uplane, int Upitch,
                        const Uint8 *Vplane, int Vpitch);
                void Lock(const SDL_Rect*, void**pixel, int*pitch);
                void Unlock();
                
                std::string& name();

                inline operator SDL_Texture*() {
                    return this->m_Texture;
                }

                inline Renderer& operator()() {
                    return this->m_TextureRenderer;
                }

            };
        }
    }

}


#endif	/* TEXTURE_H */

